package com.chen.cloud.micro.provider.user.controller;

import com.chen.cloud.micro.provider.user.entity.User;
import com.chen.cloud.micro.provider.user.repository.UserRepository;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ChenTian
 * @date 2022/6/1
 */
@RestController
@RequestMapping("/user/v1")
public class UserController {
    @Resource
    private UserRepository userRepository;

    @GetMapping("/{id}")
    public User findById(@PathVariable Long id){
        User entity = userRepository.findOne(id);
        return entity;
    }

    @PostMapping("/create")
    public User create(@RequestBody User user){
        User entity = userRepository.save(user);
        return entity;
    }

}
